#include "test.h"
#include "misc_utils.h"

/*
 * this test requires a prop file from stdin
 */
void test_prop(void)
{
    PROP_FILE_T* prop = NULL;
    printf("Input the properties, end with '.' (dot): \n");
    prop = prop_parse(stdin);

    while (1)
    {
        char buffer[200];
        STRING_T* str;
        STRING_T* value;

        printf("Query key (end with .): ");
        fgets(buffer, sizeof(buffer), stdin);
        if (buffer[0] == '.')
            break;
        str = string_trim(buffer);
        value = prop_get(prop, str->data);
        if (value == NULL)
            printf("  NULL\n");
        else
            printf("  %s\n", value->data);

        string_destroy(str);
    }
    prop_destroy(prop);
}
